package com.dinnerorders.web;

import com.dinnerorders.common.models.User;
import com.dinnerorders.web.enums.MessageCode;
import com.dinnerorders.web.helpers.MessageHelper;
import com.dinnerorders.web.windows.login.LoginWindow;
import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;
import org.springframework.beans.factory.annotation.Configurable;

/**
 * @author Nalivko Sergey
 * E-mail: snalivko93@gmail.com
 */
@Theme(value="reindeer")
@Configurable(preConstruction = true)
public class DinnerordersApplication extends UI {

    private User activeUser;

    @Override
    protected void init(VaadinRequest request) {
        addWindow(new LoginWindow(MessageHelper.getMessage(MessageCode.LOGIN_PAGE_TITLE)));
    }

    public void setActiveUser(User user) {
        this.activeUser = user;
    }

    public User getActiveUser() {
        return activeUser;
    }
}
